<%- include('../../common/header.html',{css:'common'}) %>
<%- include('../../common/script-validation.html') %>
<script id="form-select" type="application/xhtml+xml">
    <div>
        <div class="form-inline" style="width: 200px">
            <select style="width: 300px;"
                    class="form-control"
                    data-size="auto"
                    data-live-search="true"
                    title="发货仓库"
                    id="store"
            >
                <$
                stores.map(function (item) {
                $><option  value="<$=item.id $>"><$=item.name $></option>
                <$});
                $>
            </select>

        </div>
        <table class="table table-none-padding table-bordered" style="margin-bottom: 0;">
            <tr>
                <th>操作</th>
                <th >产品</td>
                <th >批号</td>
                <th >库存</th>
                <th >品质规格</th>
                <th>仓库</th>
                <th>类型</th>
                <th >免费仓储期</th>
                <th >发货数量</th>
            </tr>
            <$
            if(purchase.length){
            purchase.map(function(item,index){
            $>
            <tr>
                <td>
                    <input type="checkbox" name="selected<$=item.id$>" data-json="<$=JSON.stringify(item)$>"
                    <$ if(selected[item.id]){ $>
                    checked
                    <$}$>
                    />
                </td>
                <td>
                    <$=item.goodsName $>
                </td>
                <td>
                    <$=item.batchNum $>
                </td>
                <td>
                    <$=item.numberReceive>0?floatTool.subtract(floatTool.subtract(item.numberReceive,item.numberSended),item.numberSending):(
                    item.type==0?item.number:(floatTool.subtract(floatTool.subtract(item.number,item.numberSended),item.numberSending))) $> 吨
                </td>
                <td><$=item.quality $></td>
                <td><$=item.storeName $></td>
                <td><$=item.type==0?'车号':(item.type==1?'转货权':'介绍信') $></td>
                <td><$=formatDate(item.storeTime) $></td>
                <td>
                    <input type="text" class="form-control border-none form-inline" value=" <$ if(selected[item.id]){ $><$=selected[item.id] $><$}else{$>0<$}$>"/> 吨</td>
            </tr>
            <$ })}else{
            $> <tr><td colspan="9">没有数据</td></tr> <$
            }
            $>
        </table>
    </div>
</script>
<script type="application/xhtml+xml" id="select-batch">
    <table class="table table-none-padding table-bordered" style="margin-bottom: 0;">
        <tr>
            <th>操作</th>
            <th >产品</td>
            <th >批号</td>
            <th >库存</th>
            <th >品质规格</th>
            <th>仓库</th>
            <th>类型</th>
            <th >免费仓储期</th>
            <th >发货数量</th>
        </tr>
        <$
        if(purchase.length){
        purchase.map(function(item,index){
        $>
        <tr>
            <td>
                <input type="checkbox" name="selected<$=item.id$>" data-json="<$=JSON.stringify(item)$>"
                <$ if(selected[item.id]){ $>
                checked
                <$}$>
                />
            </td>
            <td>
                <$=item.goodsName $>
            </td>
            <td>
                <$=item.batchNum $>
            </td>
            <td>
                <$=item.numberReceive>0?floatTool.subtract(floatTool.subtract(item.numberReceive,item.numberSended),item.numberSending):(
                item.type==0?item.number:(floatTool.subtract(floatTool.subtract(item.number,item.numberSended),item.numberSending))) $> 吨
            </td>
            <td><$=item.quality $></td>
            <td><$=item.storeName $></td>
            <td><$=item.type==0?'车号':(item.type==1?'转货权':'介绍信') $></td>
            <td><$=formatDate(item.storeTime) $></td>
            <td>
                <$ if(selected[item.id]){ $>
                <input type="text" class="form-control border-none form-inline" value="<$=selected[item.id].send$>"/> 吨

                <$}$>
                <$ if(!selected[item.id]){ $>
                <input type="text" class="form-control border-none form-inline" value="0"/> 吨

                <$}$>
            </td>
        </tr>
        <$ })}else{
        $> <tr><td colspan="9">没有数据</td></tr> <$
        }
        $>
    </table>
</script>
<script type="application/xhtml+xml" id="item">
    <tr data-json="<$=JSON.stringify(item)$>"  >
        <td>
            <$=item.paperAccount  $>
        </td>
        <td>
            <$=item.goodsName $>
        </td>
        <td>
            <$=item.quality $>
        </td>
        <td>
            <$=item.number $>
        </td>
        <td style="border: 1px solid #03A9F4;">

            <input type="hidden" name="ladingOrderIds" value="<$=item.id $>" />
            <$
                var total = '',ids = '';
            item.batches.map(function(ite,idnex){
            var sp  = (item.batches.length-1==idnex?'':'|');
            total =ite.send+sp;
            ids =ite.id+sp;
            $>

            <p>批号：<$=ite.batchNum $>, 数量<$=ite.send $>吨 </p>
            <$ })$>
            <input type="hidden" name="batchNumbers" value="<$=total $>" />
            <input type="hidden" name="batchIds" value="<$=ids $>" />
        </td>
        <td>
            <$=item.paperAddress$>
        </td>
    </tr>
</script>

<script id="sender-template" type="application/xhtml+xml">
    <form class='form-horizontal create-lading-bill'>
        <div style="width: 700px;">
            <div class="form-group">
                <label class="col-sm-3 control-label">提单类型</label>
                <div class="col-sm-6">
                    <label class="radio-inline">
                        <input type="hidden" name="id" value="<$=id $>"/>
                        <input type="radio" name="type" checked="checked" disabled="disabled" value="<$=type$>"/>
                        <$=type=='0'?"车号":(type=='1'?"转货权":"介绍信")$>
                    </label>
                </div>
                <div class="col-sm-3 error-container"></div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">车号/收货公司</label>
                <div class="col-sm-6">
                    <input class="form-control" disabled="disabled" placeholder="车号/收货公司" name="carId"
                           value="<$=carId $>"/>
                </div>
                <div class="col-sm-3 error-container"></div>
            </div>
            <$if(type==0){$>
            <div class="form-group">
                <label class="col-sm-3 control-label">司机姓名/介绍人</label>
                <div class="col-sm-6">
                    <input class="form-control" disabled="disabled" placeholder="司机姓名/介绍人" name="driver"
                           value="<$=driver $>"/>
                </div>
                <div class="col-sm-3 error-container"></div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">司机电话/介绍人身份证</label>
                <div class="col-sm-6">
                    <input class="form-control" disabled="disabled" placeholder="司机电话/介绍人身份证"
                           name="driverPhone" value="<$=driverPhone $>"/>
                </div>
                <div class="col-sm-3 error-container"></div>
            </div>
            <$}$>
            <div class="form-group">
                <label class="col-sm-3 control-label"><$=type==0?'提单有效期':"免费仓储期"$></label>
                <div class="col-sm-6">
                    <input class="form-control input-date"
                           data-date-size="small"
                           data-toggle="datepicker"
                           disabled="disabled"
                           placeholder="<$=type==0?'提单有效期':'免费仓储期'$>"
                           data-rule-required='true' name="expireTime"
                           value="<$=formatDate(expireTime)$>"
                    />
                </div>
                <div class="col-sm-3 error-container"></div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">提货地</label>
                <div class="col-sm-6" style="position: relative;">
                    <$=typeof storeName =='undefined'?'':storeName $>
                </div>
                <div class="col-sm-3 error-container"></div>
            </div>
        </div>
        <a href="javascript:void(0);" style="margin: 3px;" class="btn btn-info select-batch">选择批号</a>
        <table class="table table-bordered send-order">
            <thead>
            <tr>
                <th>订单号</th>
                <th>产品</th>
                <th>品质规格</th>
                <th>本次发货数量</th>
                <th>批号</th>
                <th>客户名称</th>
            </tr>
            </thead>
            <tbody>
            <$ list.map(function(item,index){ $>
                <%-include('./sender-item.html')%>
            <$})$>
            </tbody>
        </table>
        <div style="width: 700px;">
            <div class="form-group" >
                <div class="col-sm-offset-3 col-sm-9">
                    <a data-loading-text="..." class="btn btn-primary lading-bill-check-edit">编辑</a>
                    <button type="submit" data-loading-text="..."
                            class="btn btn-danger btn-create-lading-bill">审核通过
                    </button>
                    <button type="submit" style="display: none;" data-loading-text="提交中..."
                            class="btn btn-danger ">提交
                    </button>
                </div>
            </div>
        </div>
    </form>
</script>
<script id="template-order-selected-batch" type="application/xhtml+xml">
    <tr class="class-<$=order.id$>" data-json="<$=JSON.stringify(order)$>">
        <td>
            <$=order.paperAccount $>
        </td>
        <td>
            <$=order.goodsName $>
        </td>
        <td>
            <$=order.quality $>
        </td>
        <td>
            <$=order.number $> 吨
        </td>
        <td>
            <$=item.batchNum $>
        </td>
        <td>
            <$=order.paperAddress $>
            <input type="hidden" value="<$=order.id$>" name="orderIds"/>
            <input type="hidden" value="<$=item.id$>" name="billIds"/>
            <input type="hidden" value="<$=item.batchNum $>" name="batchNum"/>
        </td>
    </tr>
</script>
<title>发货单管理-后台管理系统</title>
</head>
<body class="sub-body">
<%- include('../../common/top-nav.html') %>
<%- include('../../common/page-title.html',{navs:[
{label:'首页',url:'../../main.html'},
{label:'销售管理',url:'javascript:void(0)'},
{label:'销售发货',url:'./index.html'},
{label:'审核',url:'javascript:void(0)'},
]}) %>
<div class="content">
    <div class="panel panel-default" style="padding-bottom: 10px;">
        <br/>

    </div>
</div>
</div>
</body>
<!-- build:js ../../scripts/store/express/check.js  -->
<script type="text/javascript" src="./check.js"></script>
<!-- endbuild -->
</html>